home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
BORL_TIP
/
TI100
/
TI118.ASC
< prev
next >
Wrap
Text File
|
1991-09-11
|
3KB
|
133 lines
PRODUCT : TURBO PASCAL NUMBER : 118
VERSION : 2.00x
OS : PC-DOS, MS-DOS
DATE : March 13, 1986 PAGE : 1/2
TITLE : REDIRECTION OF INPUT/OUTPUT
This program demonstrates user defined INPUT and OUTPUT device
drivers. Use the indicated portion of the sample program as an
INCLUDE file to be inserted in declaration section of your
program files.
The MS-DOS facilities of redirection, piping, and simultaneous
printing through the use of ^P or ^PrtSc will be re-enabled. At
the beginning of your main program, place the statements
(ConInPtr:=Ofs(GetC);) and (ConOutPtr:=Ofs(PutC);). The INPUT and
OUTPUT from your programs will be redirected through the GetC
function and the PutC Procedure. Type <Ctrl> <P> at the start of
your program run and you will get output at both the CRT and the
printer.}
_________________________________________________________________
START OF INCLUDE FILE
_________________________________________________________________
program Redirect:
Type RegRecord = Record Case Integer Of
1: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Integer);
2: (AL,AH,BL,BH,CL,CH,DL,DH: Byte);
End;
Var Regs : RegRecord;
Function GetC: Byte;
Begin
Regs.AH:=8;
MsDos(Regs);
GetC:=Regs.AL;
End;
Procedure PutC(C: Byte);
Begin
Regs.AH:=2;
Regs.DL:=C;
MsDos(Regs);
End;
PRODUCT : TURBO PASCAL NUMBER : 118
VERSION : 2.00x
OS : PC-DOS, MS-DOS
DATE : March 13, 1986 PAGE : 2/2
TITLE : REDIRECTION OF INPUT/OUTPUT
________________________________________________________________
END OF INCLUDE FILE
_________________________________________________________________
Var Str : String [255];
I : integer;
Answer : char;
begin
ConInPtr:=Ofs(GetC); { Include these lines at the }
ConOutPtr:=Ofs(PutC); { start of your program }
repeat
ClrScr;
writeln ('This is a test of INPUT/OUTPUT redirection: ');
writeln;
for I := 1 to 128 do { demonstrates formated output }
write (1:5);
writeln; writeln;
writeln ('Enter a String of characters from the keyboard.');
writeln;
readln (Str);
writeln;
writeln (Str);
writeln; writeln;
writeln ('Run again? (Y/N)'); writeln;
writeln ('Type <Ctrl> <P> first to test output to PRINTER/CRT');
repeat
read (kbd,Answer);
until upcase (Answer) in ['Y','N'];
writeln;
writeln;
until upcase (Answer) = 'N';
end.